<template>
	<view>
		<customtop top_title="详情"></customtop>
    <view class="container">
      <view class="show" v-if="!loading">
        <view class="top">
          <view class="title">{{article.title}}</view>
        </view>
        <view class="content">
          <rich-text :nodes="article.content"></rich-text>
        </view>
      </view>
    </view>
	</view>
</template>

<script>
import { request } from "@/utils/http.js"
import customtop from "@/components/customtop.vue"

export default {
  components: { customtop },

  data() {
    return {
      loading: true,
      article: {},
    }
  },

  onLoad(options) {
    uni.showLoading();
    this.id = options.id;
    this.getArticle();
  },

  methods: {
    getArticle: function() {
      request.post('/article/getArticle', {id: this.id}).then(res => {
        uni.hideLoading();
        this.loading = false;
        let content = res.data.content;
        content = content.replace(/<img/gi, '<img style="max-width:100%; height:auto;"');
        res.data.content = content;
        this.article = res.data;
      })
    },
  }
}
</script>

<style>
@import url("article.css");
page {
  padding-bottom: 50rpx;
}
</style>
